<?php
/*
 * This file is part of SoftSite.
 *
 * (c) 2012 Steve Tredinnick
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 *
 *
 * @package softsite
 * @author  Steve Tredinnick <steve.tredinnick@gmail.com>
 */

namespace Controllers;

use Lib\Forms\Elements;

class TestForm_Controller extends \Classes\BaseController
{

    public function index()
    {
        $this->form->setFormName("TestForm");
        $this->form->setFormMethod("post");
        $this->form->OpenFieldSet("SteveTestFieldSet","SteveTestFieldSet Legend");
        $this->BuildTestButton();
        $this->BuildTestCheckbox();
        $this->form->CloseFieldSet();
        $this->RenderFormToTemplate();
        $this->DisplayView();
    }

    private function BuildTestButton()
    {
        $button = new Elements\ButtonElement();
        $button->SetAutoFocus();
        //$button->SetDisabled();
        $button->SetFormAction("http://localhost");
        $button->SetFormMethod("post");
        $button->SetFormNoValidate();
        $button->SetFormTarget("_top");
        $button->SetImage("image");
        $button->SetName("SteveTestButtonName");
        $button->SetText("SteveTestButtonText");
        $button->SetType("submit");
        $button->SetValue("SteveTestButtonValue");
        $this->form->AddElement($button);
    }

    private function BuildTestCheckbox()
    {
        $checkbox = new Elements\CheckBoxElement();
        $checkbox->SetName("TestCheckBox");
        $checkbox->SetChecked(true);
        $checkbox->SetLabel("Test Checkbox Label");
        $checkbox->SetText("Test Checkbox Text");
        $this->form->AddElement($checkbox);
    }
}
